<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>会议周期</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../../../static/layui/dist/layuiadmin/layui/css/layui.css" media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
  <style>

  </style>
</head>

<body>

  <div style="margin: 30px ;">
    <div class="layui-fluid">
      <div class="layui-row">
        <div class="layui-col-xs-6">
          <div class="demoTable">
            搜索会议：
            <div class="layui-inline">
              <input class="layui-input" name="keyword" id="demoReload" autocomplete="off">
            </div>
            <button class="layui-btn" data-type="reload">搜索</button>
            <button class=" layui-btn" onclick="add()">添加</button>

          </div>
        </div>
      </div>
    </div>
    <table class="layui-hide" id="LAY_table_meet" lay-filter="useruv"></table>
  </div>

  </div>

  <script src="../../../static/layui/dist/layuiadmin/layui/layui.js" charset="utf-8"></script>
  <!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->
  <script>
    function add() {
      layui.use('layer', function () {
        LAY_table_meet
        layer.open({
          type: 2,
          content: ["add_meet"],   //添加页，后台controller转发到指定页
          area: ["100%", "100%"],
          title: ['新建会议'],
          fixed: false,
          //maxmin: true,
          shadeClose: true,
          end: function () {  //刷新页面
            location.reload();
          }
        })
      })
    }

    layui.use('table', function () {
      var table = layui.table;


      table.render({
        elem: '#LAY_table_meet'
        , url: 'operate_meet'
        , cols: [[
          { field: 'id', title: 'ID', width: 80, align: 'center', sort: true, fixed: true }
          , { field: 'add_user', title: '发布人', align: 'center', width: 200, edit: true }
          , { field: 'meetname', title: '会议主题', align: 'center', width: 200, edit: true }
          , { field: 'place', title: '会议地点', align: 'center', width: 200 }
          , { field: 'date', title: '会议日期', align: 'center', width: 180, sort: true }
          , { field: 'start_time', title: '开始时间', align: 'center', width: 180, sort: true }
          , { field: 'finish_time', title: '结束时间', align: 'center', sort: true }
          , { field: 'right', title: '操作', align: 'center', width: 320, toolbar: "#barDemo", }
        ]]
        , id: 'testReload'
        , page: true
        , height: 600
        , size: "lg"

      });
      var $ = layui.$, active = {
        reload: function () {
          LAY_table_meet
          var demoReload = $('#demoReload');

          table.reload('testReload', {
            where: {
              keyword: demoReload.val()
            }
          });
        }
      };
      $('.demoTable .layui-btn').on('click', function () {

        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
      });
      table.on('tool(useruv)', function (obj) {
        var data = obj.data;
        if (obj.event === 'detail') {
          layui.use('layer', function () {
            LAY_table_meet
            layer.open({
              type: 2,
              content: ["detail_meet?id=" + data.id],   //添加页，后台controller转发到指定页
              area: ["100%", "100%"],
              title: ['查看会议'],
              fixed: false,
              //maxmin: true,
              shadeClose: true,
              end: function () {  //刷新页面
                location.reload();
              }
            })
          })
        } else if (obj.event === 'del') {
          layer.confirm('真的删除行么', function (index) {

            $.ajax({
              url: "del_meet",
              type: "POST",
              data: { "id": data.id },
              dataType: "json",
              success: function (data) {

                if (data.state == 1) {
                  //删除这一行
                  obj.del();
                  //关闭弹框
                  layer.close(index);
                  layer.msg("删除成功", { icon: 6 });
                } else {
                  layer.msg("删除失败", { icon: 5 });
                }
              }
            });
          });
        } else if (obj.event === 'edit') {
          layui.use('layer', function () {
            LAY_table_meet
            layer.open({
              type: 2,
              content: ["edit_meet?id=" + data.id],   //添加页，后台controller转发到指定页
              area: ["100%", "100%"],
              title: ['编辑会议'],
              fixed: false,
              //maxmin: true,
              shadeClose: true,
              end: function () {  //刷新页面
                location.reload();
              }
            })
          })
        }
      });
    });


  </script>
  <script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-mini" lay-event="detail">查看</a>
    <a class="layui-btn layui-btn-mini" lay-event="edit">编辑</a>
    <a class="layui-btn layui-btn-danger layui-btn-mini" lay-event="del">删除</a>
</script>
</body>

</html>